<meta name="description" content="<?php echo $structure->getFMetaDescription() ?>" />
<meta name="keywords" content="<?php echo $structure->getFMetaKeyword() ?>" />

<div data-role="page" id="article<?php echo $structure->getFId() ?>">
    <style type="text/css">
        .ui-selectmenu {
            max-width: 350px;
            padding: 6px;
            position: absolute;
            width: 80%;
            z-index: 1001 !important;
        }
        .ui-content {
            padding: 15px;
        }
        #header {
            height: 55px;
        }
        #header_tc {
            height: 83px;
        }
    </style>
    <script type="text/javascript">
        $(function() {
            $("#dialogSubmenuTitle").click(function(){
                $(this).parent().addClass("ui-btn-active");
                $("#navigationForm").attr("action", $(this).data("link"));
                $("#articleId").val($(this).data("articleId"));
                $("#navigationForm").submit();
            });
            $('#navigationDiv a').live('click', function() {
                $(".ui-icon-arrow-d").removeClass("ui-icon-arrow-d").addClass("ui-icon-arrow-r");

                var obj = $(this).parent().next();
                var pageId = $(this).attr("refId");
                var refName = $(this).attr("refName");
                var link = $(this).attr("link");
                $(obj).removeClass("ui-icon-arrow-r").addClass("ui-icon-arrow-d");

                $.ajax({
                    type : 'POST',
                    url : "/m/fetchSubmenu",
                    dataType : 'json',
                    cache: false,
                    data: {
                        pageId : pageId
                    },
                    success : function(data) {
                        $("#divTaylorUni").hide();
                        $("#divTaylorCollege").hide();
                        $("#college-menu").html("");
                        $("#dialogSubmenuTitle").html(refName).data("link", link).data("articleId", pageId);
                        var contentLink = "";

                        if ($(data.aaData).length > 0) {
                            jQuery.each(data.aaData, function(key, value) {
                                contentLink += "<li class='ui-btn ui-btn-icon-right ui-li ui-btn-up-a' data-icon='false' data-option-index='2' role='option'";
                                contentLink += "tabindex='-1' data-theme='a' aria-selected='false'>";
                                contentLink += "<div aria-hidden='true' class='ui-btn-inner ui-li'>";

                                var tmp = "";
                                var content = "";
                                var target = "_self";
                                var link = "/m/article?articleId=" + value.f_id;
                                var arrs = value.f_name.split(" ");
                                jQuery.each(arrs, function(key, value) {
                                    tmp += value + " ";
                                    if (tmp.length > 35) {
                                        content += tmp + "<br>";
                                        tmp = "";
                                    }
                                });

                                if (value.external_link == "1") {
                                    link = value.f_link;
                                    target = "_blank";
                                } else if (value.external_link == "2") {
                                    link = value.f_link;
                                }
                                content += tmp;
                                contentLink += "<div class='ui-btn-text'><a href='" + link + "' class='ui-link-inherit' target='" + target + "'  data-ajax='false'>" + content + "</a><span class='ui-icon ui-icon-arrow-r ui-icon-shadow'></span></div>";
                                contentLink += "</div>";
                                contentLink += "</li>";
                            });
                            $("#selectSchool-menu").html(contentLink);
                            $("#dialogSubmenu").show();
                        } else {
                            $("#navigationForm").attr("action", "/m/article");
                            $("#articleId").val(pageId);
                            $("#navigationForm").submit();
                        }
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        //alert("Your login attempt was not successful. Please try again.");
                    }
                });
            });
            $('#closeDialog').live('click', function() {
                $(".ui-icon-arrow-d").removeClass("ui-icon-arrow-d").addClass("ui-icon-arrow-r");
                $("#dialogSubmenu").hide();
            });
            $('#favouriteLink').live('click', function() {
                $.ajax({
                    type : 'POST',
                    url : "/m/fetchFavouriteLink",
                    dataType : 'json',
                    cache: false,
                    data: {
                    },
                    success : function(data) {
                        $("#divTaylorUni").hide();
                        $("#divTaylorCollege").hide();
                        $("#college-menu").html("");
                        $("#dialogSubmenuTitle").html("Favourite");
                        var contentLink = "";
                        var collegeContentLink = "";
                        jQuery.each(data.aaData, function(key, value) {
                            if (value.root == 1) {
                                contentLink += "<li class='ui-btn ui-btn-icon-right ui-li ui-btn-up-a' data-icon='false' data-option-index='2' role='option'";
                                contentLink += "tabindex='-1' data-theme='a' aria-selected='false'>";
                                contentLink += "<div aria-hidden='true' class='ui-btn-inner ui-li'>";
                                //contentLink += "<div class='ui-btn-text wordwrap'><a href='" + value.f_link + "' class='ui-link-inherit' target='_blank'>" + value.f_name + "</a><span class='ui-icon ui-icon-arrow-r ui-icon-shadow'></span></div>";
                                contentLink += "<div class='ui-btn-text wordwrap'><a href='/m/article?articleId=" + value.f_id + "' data-ajax='false' class='ui-link-inherit' target='_self'>" + value.f_name + "</a><span class='ui-icon ui-icon-arrow-r ui-icon-shadow'></span></div>";
                                contentLink += "</div>";
                                contentLink += "</li>";
                            } else {
                                collegeContentLink += "<li class='ui-btn ui-btn-icon-right ui-li ui-btn-up-a' data-icon='false' data-option-index='2' role='option'";
                                collegeContentLink += "tabindex='-1' data-theme='a' aria-selected='false'>";
                                collegeContentLink += "<div aria-hidden='true' class='ui-btn-inner ui-li'>";
                                //collegeContentLink += "<div class='ui-btn-text wordwrap'><a href='" + value.f_link + "' class='ui-link-inherit' target='_blank'>" + value.f_name + "</a><span class='ui-icon ui-icon-arrow-r ui-icon-shadow'></span></div>";
                                collegeContentLink += "<div class='ui-btn-text wordwrap'><a href='/m/article?articleId=" + value.f_id + "' data-ajax='false' class='ui-link-inherit' target='_self'>" + value.f_name + "</a><span class='ui-icon ui-icon-arrow-r ui-icon-shadow'></span></div>";
                                collegeContentLink += "</div>";
                                collegeContentLink += "</li>";
                            }
                        });
                        $("#selectSchool-menu").html(contentLink);
                        $("#college-menu").html(collegeContentLink);
                        if ($(contentLink).length > 0)
                            $("#divTaylorUni").show();
                        if ($(collegeContentLink).length > 0)
                            $("#divTaylorCollege").show();
                        $("#dialogSubmenu").show();
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        //alert("Your login attempt was not successful. Please try again.");
                    }
                });
            });
        });
    </script>

    <div id="header<?php if ($level1Id == 2) echo "_tc" ?>">
        <a href="/m/landing?article=<?php echo $level1Id ?>" data-ajax="false">
    	    <img src="/uploads/<?php echo $headerLogo ?>" class="logo" onerror="this.src='/images/mobile/not_available.gif';"/>
        </a>
        <a href="#" data-ajax="false" data-rel="back" class="ui-btn-right">
            <img src="/images/mobile/btn_close.png" class="menu" style="<?php if ($level1Id == 2) echo "top: 25px" ?>"/>
        </a>
    </div>

    <form action="forms-sample-response.php" id="navigationForm" method="get" data-ajax="false">
    <input type="hidden" name="articleId" id="articleId">
    <div data-role="content" id="navigationDiv">
        <ul data-role="listview">
            <?php
            if (isset($switchModulePageId)) {
            ?>
                <li><a href="/m/landing?article=<?php echo $switchModulePageId ?>" data-ajax="false" style="min-height: 20px; padding: 0.7em 5px">
                    <table width="100%"><tr><td>
                    <img height="55px" src="/uploads/<?php echo $switchModuleLogo ?>"/>
					</td><td>
                    <h3><?php echo $switchModuleTitle ?></h3>
                    </td></tr></table>
                </a></li>
            <?php } ?>
            <?php
            $count = 0;
            foreach ($footer_menus as $tbl_structure):
            	if($tbl_structure->getFContent() == "") continue;
                $link = "/m/article?articleId=".$tbl_structure->getFId();
                $target = "_self";
                if ($tbl_structure->getExternalLink() == "1") {
                    $link = $tbl_structure->getFLink();
                    $target = "_blank";
                } else if ($tbl_structure->getExternalLink() == "2") {
                    $link = $tbl_structure->getFLink();
                }
                if (isset($favoriteList) && $favoriteList == "T")
                {
                    echo "<li><a href='".$link."' style='min-height: 20px' data-ajax='false'>";
                    echo "<h3>".$tbl_structure->getFName()."</h3>";
                    echo "</a></li>";
                } else {
            ?>
                    <li><a href="#" style="min-height: 20px" refName="<?php echo $tbl_structure->getFName() ?>" refId="<?php echo $tbl_structure->getFId() ?>" link="<?php echo $link ?>" target="<?php echo $target ?>">
                        <img height="55px" src="/uploads/<?php echo $tbl_structure->getFMenuIcon() ?>"/>

                        <h3><?php echo $tbl_structure->getFName(); ?></h3>
                    </a></li>
            <?php
                }
                endforeach;
            ?>
        </ul>
    </div>
    </form>
    <div data-role="footer" data-id="foo1" data-position="fixed">
        <div style="padding: 15px; display: block; float: left; width: 80%" id="favouriteLink">
            <img align="absmiddle" class="fav_img" src="/images/mobile/favorite_star.png">
            <!--<span style="font-size: 20px; padding-left: 25px;">My Favourites</span>-->
        </div>
    </div>
</div>

<div id="dialogSubmenu" class="ui-selectmenu ui-overlay-shadow ui-corner-all ui-body-a pop in" style="top: 100.5px; left: 30px; display: none; z-index: 1001">
    <div class="ui-header ui-bar-a" style="position: relative;">
        <h1 class="ui-title" id="dialogSubmenuTitle" style="cursor: pointer">About Taylor's</h1>
        <a id="closeDialog" href="#" class="ui-btn-left ui-btn ui-btn-up-a ui-btn-icon-notext ui-btn-corner-all"
                data-iconpos="notext" data-icon="delete"
                title="Close" data-theme="a"
                style="display: inline-block;">
            <span aria-hidden="true" class="ui-btn-inner ui-btn-corner-all">
                <span class="ui-btn-text">Close</span>
                <span class="ui-icon ui-icon-delete ui-icon-shadow"></span>
            </span>
        </a>
    </div>
    <div class="ui-header ui-bar-a" style="position: relative; display: none" id="divTaylorUni">
        <h1 class="ui-title" id="dialogSubmenuTitleTaylorUni" style="font-size: 12px">Taylor’s University</h1>
    </div>
    <ul class="ui-selectmenu-list ui-listview" id="selectSchool-menu" role="listbox"
        aria-labelledby="selectSchool-button" data-theme="a">

        <li class="ui-btn ui-btn-icon-right ui-li ui-btn-up-a" data-icon="false" data-option-index="2" role="option"
            tabindex="-1" data-theme="a" aria-selected="false">
            <div aria-hidden="true" class="ui-btn-inner ui-li">
                <div class="ui-btn-text">
                    <a href="#" class="ui-link-inherit">Our Story</a><span class="ui-icon ui-icon-arrow-r ui-icon-shadow"></span></div>
            </div>
        </li>
    </ul>
    <div class="ui-header ui-bar-a" style="position: relative; display: none" id="divTaylorCollege">
        <h1 class="ui-title" id="dialogSubmenuTitleTaylorCollege" style="font-size: 12px">Taylor’s College</h1>
    </div>
    <ul class="ui-selectmenu-list ui-listview" id="college-menu" role="listbox"
        aria-labelledby="selectSchool-button" data-theme="a">

        <li class="ui-btn ui-btn-icon-right ui-li ui-btn-up-a" data-icon="false" data-option-index="2" role="option"
            tabindex="-1" data-theme="a" aria-selected="false">
            <div aria-hidden="true" class="ui-btn-inner ui-li">
                <div class="ui-btn-text">
                    <a href="#" class="ui-link-inherit">Our Story</a><span class="ui-icon ui-icon-arrow-r ui-icon-shadow"></span></div>
            </div>
        </li>
    </ul>
</div>